//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        /**
         * 力扣
         */
        //1.字符串中的第一个唯一字符
        public int firstUniqChar(String s) {
            HashMap<Character,Integer> map = new HashMap<>();
            for(int i = 0;i < s.length();i++) {
                if(map.containsKey(s.charAt(i))) {
                    map.put(s.charAt(i),map.get(s.charAt(i)) + 1);
                } else{
                    map.put(s.charAt(i),1);
                }
            }
            for(int i = 0;i < s.length();i++) {
                if(map.get(s.charAt(i)) == 1) {
                    return i;
                }
            }
            return -1;
        }
            //2.验证回文串
        public boolean isPalindrome(String s) {
            StringBuffer buffer = new StringBuffer();
            int len = s.length();
            for(int i = 0;i < len;i++) {
                char ch = s.charAt(i);
                if(Character.isLetterOrDigit(ch)) {
                    buffer.append(Character.toLowerCase(ch));
                }
            }
            int len1 = buffer.length();
            int left = 0;
            int right = len1 - 1;
            while(left < right) {
                if(buffer.charAt(left) != buffer.charAt(right)) {
                    return false;
                }
                left++;
                right--;
            }
            return true;
        }
    }
}